/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.rememberthemilk.ui.editors;

import java.util.LinkedHashSet;
import java.util.Set;

import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorSummaryPart;
import org.eclipse.mylyn.rememberthemilk.core.RTMCorePlugin;
import org.eclipse.mylyn.rememberthemilk.ui.Logger;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;

/**
 * @author Steffen Pingel
 * @author Xiaoyang Guan (Wiki HTML preview)
 */
public class RTMTaskEditorPage extends AbstractTaskEditorPage {

	public RTMTaskEditorPage(TaskEditor editor) {
		super(editor, RTMCorePlugin.REPOSITORY_KIND);
	}
	
	@Override
	protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
		Set<TaskEditorPartDescriptor> oldDescriptors = super.createPartDescriptors(); 
		Set<TaskEditorPartDescriptor> descriptors = new LinkedHashSet<TaskEditorPartDescriptor>();
		
		for (TaskEditorPartDescriptor descriptor: oldDescriptors) {
			if (descriptor.getPath().equals(PATH_ACTIONS)) {
				descriptors.add(descriptor);
				break;
			}
		}
		
		descriptors.add(new TaskEditorPartDescriptor(ID_PART_SUMMARY) {
			@Override
			public AbstractTaskEditorPart createPart() {
				return new RtmTaskEditorSummaryPart();
			}
		}.setPath(PATH_HEADER));
		
		descriptors.add(new TaskEditorPartDescriptor("Tags") {
			@Override
			public AbstractTaskEditorPart createPart() {
				AbstractTaskEditorPart part = new RtmTaskTagPart();
				return part;
			}
		}.setPath(PATH_ATTRIBUTES));
		return descriptors;
//		return super.createPartDescriptors();
	}
}
